package com.sz.app.oss.api.logistics.order;

import com.sz.biz.app.web.BaseController;
import com.sz.biz.logistics.ord.service.BizOperationLogService;
import com.sz.common.base.dto.ResultDto;
import com.sz.biz.logistics.ord.dto.OrdOperLogData;
import com.sz.biz.logistics.ord.dto.OrdOperLogDto;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Function: TODO: ADD FUNCTION <br>
 * Author: yanhong.xiao.<br>
 * Date: 2017-10-12 17:59:00.
 */

@RestController
@RequestMapping("/api/v1/order/logs")
@Api(description = " ", tags = "036-007、订单操作日志")
public class OrdOperationLogController extends BaseController {

    @Autowired
    private BizOperationLogService bizOperationLogService;


    @ApiOperation(value = "查询订单的操作日志列表", notes = "查询订单的操作日志列表", position = 1)
    @ApiImplicitParams({ @ApiImplicitParam(name = "sort", value = "排序的字段", dataType = "string", paramType = "query"), @ApiImplicitParam(name = "asc", value = "排序方式", dataType = "boolean", paramType = "query", defaultValue =
            "true")
    })
    @RequestMapping(value = "/{orderId}", method = RequestMethod.GET)
    public ResultDto findLogs(@ApiParam(value = "订单id", required = true) @PathVariable("orderId") Integer orderId, @RequestParam(required = false) String sort,
                              @RequestParam(required = false, defaultValue = "true") Boolean asc) {
        ResultDto result = new ResultDto();
        List<OrdOperLogDto> resultData = bizOperationLogService.getLogsByOrderId(orderId,sort,asc);
        result.setData(resultData);
        return result;
    }

    @ApiOperation(value = "查询订单的操作日志详情", notes = "查询订单的操作日志详情", position = 2)
    @RequestMapping(value = "/detail/{logId}", method = RequestMethod.GET)
    public ResultDto findLogById(@ApiParam(value = "日志id", required = true) @PathVariable("logId") Integer logId) {
        ResultDto result = new ResultDto();
        OrdOperLogData logData = bizOperationLogService.getById(logId);
        result.setData(logData);
        return result;
    }

}
